<script>
export default {
  name: 'VideoPreview',
  data() {
    return {
      src: null,
      visible: false,
      title: null,
      fullScreen: false
    }
  },
  methods: {
    $show(e, n) {
      this.src = null
      this.src = e
      this.title = n
      this.visible = true
    },
    handleChangeFull() {
      this.fullScreen = !this.fullScreen
    },
    handleClose() {
      this.visible = false
    }
  }
}
</script>

<template>
  <el-dialog :visible.sync='visible' :close-on-click-modal='false' :show-close='false' :fullscreen='fullScreen' width='640px' destroy-on-close>
    <template #title>
      <div class='dialog-header'>
        <span>{{ title }}</span>
        <div class='btn-group'>
          <el-button v-if='fullScreen' type='info' icon='el-icon-crop' size='mini' @click='handleChangeFull' />
          <el-button v-if='!fullScreen' type='info' icon='el-icon-full-screen' size='mini' @click='handleChangeFull' />
          <el-button type='danger' icon='el-icon-close' size='mini' @click='handleClose' />
        </div>
      </div>
    </template>
    <div style='display: flex; justify-content: center;'>
      <video :src='src' style='width: 100%; height: 100%;' width='100%' height='100%' autoplay controls muted />
    </div>
  </el-dialog>
</template>

<style lang='scss'>
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;

  .btn-group {
    display: flex;
    align-items: center;
  }
}
</style>
